package project.parser.ast.stats;

import project.environments.DynamicEnv;
import project.environments.StaticEnv;
import project.parser.ast.exps.Exp;

public class ExpStat implements Stat { //implementa Stat perche' e' un statement
	private final Exp exp;

	public ExpStat(Exp exp) {
		this.exp = exp;
	}

	@Override
	public void typecheck(StaticEnv senv) {
		if (!isNull()) //controlla che l'espressione non sia nulla
			exp.typecheck(senv);
	}

	@Override
	public void evaluate(DynamicEnv denv) {
		if (!isNull())
			exp.evaluate(denv);
	}

	public boolean isNull() {
		return this.exp == null;
	}
}
